import 'package:flutter/material.dart';
import 'package:wanflutter/manager/app_manager.dart';
import 'package:wanflutter/ui/page/page_article.dart';
import 'package:wanflutter/ui/page/page_register.dart';
import 'package:wanflutter/ui/widget/main_drawer.dart';

void main() => runApp(new ArticleApp());

class ArticleApp extends StatelessWidget {

  // 测试用 注册单页
  Widget registerPage(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("文章" ,
          style: const TextStyle(color: Colors.white),
        ),
      ),
      body: ElevatedButton(
        child: Text("注册" ,
          style: TextStyle(color: Colors.white, fontSize: 18.0),
        ),
        style: ButtonStyle(
          backgroundColor: MaterialStateProperty.all(Colors.blue)
        ),
        onPressed: (){
          Navigator.push(context, MaterialPageRoute(builder: (_){
            return RegisterPage();
          }));
        },
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    // 初始化了sp数据库
    AppManager.initApp();

    return new MaterialApp(
      // home: Builder(builder: registerPage,),  // 注册页测试
      home: new Scaffold(   // scaffold组件包，类似脚手架，包含了drawer
        appBar: new AppBar(
          title: new Text(
            '文章',
            style: const TextStyle(color: Colors.white),
          ),
        ),
        drawer: Drawer(
          child: MainDrawer(),
        ),
        body: new ArticlePage(),  // 主页主要内容
        ),
      );
  }

}
